package auto.app.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum ConnectionConfigurationType {

    MYSQL("mysql","MySql"),
    SQLSERVER("sqlserver","SQLSever"),
    ORACLE("oracle","Oracle"),
    POSTGRESQL("postgresql","PostgreSql")
    ;
    private String connectionType;
    private String connectionMsg;

    public String getConnectionType() {
        return connectionType;
    }

    public void setConnectionType(String connectionType) {
        this.connectionType = connectionType;
    }

    public String getConnectionMsg() {
        return connectionMsg;
    }

    public void setConnectionMsg(String connectionMsg) {
        this.connectionMsg = connectionMsg;
    }

    ConnectionConfigurationType(String connectionType, String connectionMsg) {
        this.connectionType = connectionType;
        this.connectionMsg = connectionMsg;
    }

    @Override
    public String toString() {
        return "ConnectionConfigurationType{" +
                "connectionType='" + connectionType + '\'' +
                ", connectionMsg='" + connectionMsg + '\'' +
                '}';
    }

    /**
     * 转为数据
     *
     * @return 枚举对象数组
     */
    public static List<Map<String, String>> toList() {
        List<Map<String, String>> list = new ArrayList<>();
        for (ConnectionConfigurationType item : ConnectionConfigurationType.values()) {
            Map<String, String> map = new HashMap<>();
            map.put("connectionType", item.getConnectionType());
            map.put("connectionMsg", item.getConnectionMsg());
            list.add(map);
        }
        return list;
    }
}
